package com.cms.recursoshumanos.component.dialog;

import com.example.frontendrecursoshumanos.R;
import com.cms.recursoshumanos.constant.Constant;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.NumberPicker;

public class CustomCantidadDiaDialog extends Dialog 
{

    private NumberPicker mSpinner;
    public interface CantidadDialogListener 
  	{
        public void ready(int dia_select);
        public void cancelled();
    }

    private CantidadDialogListener mReadyListener;

    public CustomCantidadDiaDialog(Context context, CantidadDialogListener readyListener) 
    {
        super(context);
        this.setTitle("Solicitud de Dias de Vacaciones");
        mReadyListener = readyListener;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.elementos_spinner_cantidad_dia_vac_picker);
        mSpinner = (NumberPicker) findViewById (R.id.npDiasCant);
        mSpinner.setMaxValue(Constant.MAX_VALUE_VACACIONES);
        mSpinner.setMinValue(Constant.MIN_VALUE_VACACIONES );
        
        Button buttonOK = (Button) findViewById(R.id.dialogOK);
        Button buttonCancel = (Button) findViewById(R.id.dialogCancel);
        buttonOK.setOnClickListener(new android.view.View.OnClickListener()
        {
            public void onClick(View v) 
            {
                
                mReadyListener.ready(mSpinner.getValue());
                CustomCantidadDiaDialog.this.dismiss();
            }
        });
        buttonCancel.setOnClickListener(new android.view.View.OnClickListener(){
            public void onClick(View v) 
            {
                mReadyListener.cancelled();
                CustomCantidadDiaDialog.this.dismiss();
            }
        });
    }
}